package com.base.cn.platform.os.service.exam.record;

import com.base.cn.platform.os.service.FeignAuthConfig;
import com.base.cn.platform.os.service.exam.ExamBaseService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 试题记录接口
 *
 * @author s.li
 * @date 2018/12/11
 */
@FeignClient(name = ExamBaseService.appName,configuration = FeignAuthConfig.class)
public interface ExamQuestionRecordService extends ExamBaseService {

    /**
     * 加载试题记录列表
     * @param condition 查询条件
     * @param currentPage 页码
     * @param pageSize 查询数量
     * @return PageInfo<ExamQuestionRecord>
     */
    @RequestMapping(contextPath + "/findExamQuestionRecordListPage")
    Map<String,Object> findExamQuestionRecordListPage(@RequestBody Map<String, Object> condition,
                                                      @RequestParam("currentPage") int currentPage,
                                                      @RequestParam("pageSize") int pageSize);

    /**
     * 保存试题记录作答内容
     * @param userId 用户ID
     * @param examRecordId 考试记录ID
     * @param questionRecordId 试题记录ID
     * @param userAnswer 用户答案
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/saveQuestionRecord")
    Map<String,Object> saveQuestionRecord(@RequestParam("userId") BigDecimal userId,
                                          @RequestParam("examRecordId") BigDecimal examRecordId,
                                          @RequestParam("questionRecordId") BigDecimal questionRecordId,
                                          @RequestParam("userAnswer") String userAnswer);

    /**
     * 修改试题记录的分数
     * @param userId 用户ID
     * @param examRecordId 考试记录ID
     * @param id 试题记录ID
     * @param type 类型，1不是试题，2是子试题
     * @param index 子试题的下标
     * @param score 分数
     * @param comment 评语
     * @param isWeb 是否来自前台
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/updateQuestionRecordScore")
    Map<String,Object> updateQuestionRecordScore(@RequestParam("userId") BigDecimal userId,
                                                 @RequestParam(value = "examRecordId", required = false) BigDecimal examRecordId,
                                                 @RequestParam("id") BigDecimal id,
                                                 @RequestParam("type") int type,
                                                 @RequestParam("index") int index,
                                                 @RequestParam("score") int score,
                                                 @RequestParam(value = "comment", required = false) String comment,
                                                 @RequestParam("isWeb") boolean isWeb);

    /**
     * 获取考试首页用户的能力透析数据
     * @param userId 用户ID
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/getWebIndexUserCapability")
    Map<String,Object> getWebIndexUserCapability(@RequestParam("userId") BigDecimal userId);

    /**
     * 获取用户考试统计
     * @param userId 用户ID
     * @param period 周期单位，1天，2周，3月
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/getUserEvaluation")
    Map<String,Object> getUserEvaluation(@RequestParam("userId") BigDecimal userId,
                                         @RequestParam("period") int period);

    /**
     * 获取用户薄弱考点
     * @param userId 用户ID
     * @return List<Map<String,Object>>
     */
    @RequestMapping(contextPath + "/getUserWeakness")
    List<Map<String,Object>> getUserWeakness(@RequestParam("userId") BigDecimal userId);

   /* *//**
     * 创建用户试题记录表
     * @param userId 用户ID
     *//*
    @RequestMapping(contextPath + "/createUserQuestionRecordTable")
    void createUserQuestionRecordTable(@RequestParam("userId") BigDecimal userId);*/
}
